(function($) {
	$.widget( "custom.progressbar", {
	    options: {
	        value: 0,
	        dummy: 'dummy'
	    },
	    _create: function() {
	        this.element.addClass( "progressbar" );
	        this.refresh();
	    },
	    // create a public method
//	    value: function( value ) {
//	        // no value passed, act as a getter
//	        if ( value === undefined ) {
//	            return this.options.value;
//	        // value passed, act as a setter
//	        } else {
//	            this.options.value = this._constrain( value );
//	            var progress = this.options.value + "%";
//	            this.element.css("width", progress);
//	            this.element.text( progress );
//	        }
//	    },
//	    dummy: function( text ) {
//	    	if ( text === undefined ) {
//	            return this.options.dummy;
//	        // value passed, act as a setter
//	        } else {
//	            this.options.dummy = text;
//	        }
//	    },
	    _setOption: function( key, value ) {
	        if ( key === "value" ) {
	            value = this._constrain( value );
	        }
	        $.Widget.prototype._setOption.apply( this, arguments );
//	        this._super( key, value );
	    },
	    _setOptions: function( options ) {
	    	$.Widget.prototype._setOptions.apply( this, arguments );
//	        this._super( options );
	        this.refresh();
	    },
	    refresh: function() {
	        var progress = this.options.value + "%";
	        this.element.css("width", progress);
	        this.element.text( progress );
	        if( this.options.value == 100 ) {
	            this._trigger( "complete", null, this.options );
	        }
	    },
	    // create a private method
	    _constrain: function( value ) {
	        if ( value > 100 ) {
	            value = 100;
	        }
	        if ( value < 0 ) {
	            value = 0;
	        }
	        return value;
	    },
	    destroy: function() {
	    	this.element.remove();
	    }
	});
}(jQuery));
